home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / share / 11 / setup.exe / %MAINDIR% / DEMOS / CIFTP / FTPEXP / session.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-09-07  |  10.2 KB  |  245 lines

  1. VERSION 4.00
  2. Begin VB.Form Session 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "FTP Session - (hidden)"
  5.    ClientHeight    =   1695
  6.    ClientLeft      =   1500
  7.    ClientTop       =   2055
  8.    ClientWidth     =   4590
  9.    Height          =   2100
  10.    Icon            =   "Session.frx":0000
  11.    Left            =   1440
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1695
  17.    ScaleWidth      =   4590
  18.    ShowInTaskbar   =   0   'False
  19.    Top             =   1710
  20.    Width           =   4710
  21.    Begin VB.Label lblReadMe 
  22.       AutoSize        =   -1  'True
  23.       Caption         =   "Host files and directories are returned in the ""Files"" collection and processed in the 'ListFTPItems' proc."
  24.       ForeColor       =   &H00800000&
  25.       Height          =   390
  26.       Index           =   2
  27.       Left            =   285
  28.       TabIndex        =   1
  29.       Top             =   900
  30.       Width           =   3915
  31.       WordWrap        =   -1  'True
  32.    End
  33.    Begin CIFTPLib.CIFTP ciSession 
  34.       Height          =   450
  35.       Left            =   300
  36.       Top             =   120
  37.       Width           =   480
  38.       _Version        =   65537
  39.       _ExtentX        =   847
  40.       _ExtentY        =   794
  41.       _StockProps     =   0
  42.       AccessChannelConnectionWAV=   ""
  43.       AccessChannelClosedWAV=   ""
  44.       DataChannelConnectionWAV=   ""
  45.       DataChannelClosedWAV=   ""
  46.       FileClosedWAV   =   ""
  47.       ListBoxesPopulatedWAV=   ""
  48.       SocketClosedWAV =   ""
  49.       WSAErrorWAV     =   ""
  50.       HostName        =   ""
  51.       HostAddress     =   ""
  52.       RemoteFileName  =   ""
  53.       LoginName       =   ""
  54.       Password        =   ""
  55.       RepresentationType=   ""
  56.       WorkingDirectory=   "/"
  57.    End
  58.    Begin VB.Label lblReadMe 
  59.       Caption         =   "Crescent FTP Control"
  60.       ForeColor       =   &H00800000&
  61.       Height          =   195
  62.       Index           =   0
  63.       Left            =   930
  64.       TabIndex        =   0
  65.       Top             =   285
  66.       Width           =   1995
  67.       WordWrap        =   -1  'True
  68.    End
  69. Attribute VB_Name = "Session"
  70. Attribute VB_Creatable = False
  71. Attribute VB_Exposed = False
  72. Option Explicit
  73. '<Public>---------------------------------------------
  74. Public Connected        As Boolean
  75. Public GotDirectory     As Boolean
  76. Public TimedOut         As Boolean
  77. Public ServerNode       As Node
  78. Public ThisExplorer     As Form
  79. Public ThisCallback     As FTPCallback
  80. Public ThisServer       As FTPServer
  81. Public WorkingDir       As String
  82. '</Public>--------------------------------------------
  83. '<Private>--------------------------------------------
  84. Private Alias           As String
  85. Private GetListing      As Boolean
  86. '</Private>-------------------------------------------
  87. Private Sub ciSession_AccessControlChannelClosed()
  88.     Connected = False
  89.     Call Status.ShowStatus(Alias & ": the access control channel was closed", , , "Status", vbBlue)
  90. End Sub
  91. Private Sub ciSession_AccessControlChannelConnection()
  92.     Connected = True
  93.     Call Status.ShowStatus(Alias & ": the access control channel was connected", , , "Status", vbBlue)
  94. End Sub
  95. Private Sub ciSession_AccessControlPacketReceived(ByVal Packet As String)
  96.     '---- packet received on the access control channel
  97.     Call Status.ShowStatus(Alias & vbCrLf & Packet, , , "Packet", vbRed)
  98. End Sub
  99. Private Sub ciSession_DataControlChannelClosed()
  100.     GotDirectory = True
  101.     Call Status.ShowStatus(Alias & ": the data control channel was closed", , , "Status", vbBlue)
  102. End Sub
  103. Private Sub ciSession_DataControlChannelConnection()
  104.     Call Status.ShowStatus(Alias & ": the data control channel was connected", , , "Status", vbBlue)
  105. End Sub
  106. Private Sub ciSession_DataControlPacketReceived(ByVal Packet As String, ByVal bytes_in As Integer)
  107.     '---- packet received on the access control channel
  108.     Call Status.ShowStatus(Alias & vbCrLf & Packet, , , "Packet", vbRed)
  109. End Sub
  110. Private Sub ciSession_DataPortSet()
  111.     '---- connect to the data channel
  112.     ciSession.ConnectToDataChannel
  113. End Sub
  114. Private Sub ciSession_GotDirectory()
  115.     GotDirectory = True
  116.     Call Status.ShowStatus(Alias & ": got directories and files; adding to TreeView", , , "Status", vbBlue)
  117.     If GetListing Then
  118.         '---- turn off redraw on TreeView and ListView
  119.         Call SendMessage(ThisExplorer.Tree.hwnd, WM_SETREDRAW, REDRAWOFF, 0&)
  120.         Call SendMessage(ThisExplorer.List.hwnd, WM_SETREDRAW, REDRAWOFF, 0&)
  121.         
  122.         Call ThisCallback.ListFTPItems(Me, ThisExplorer, ServerNode)
  123.         
  124.         '---- set some properties on the explorer
  125.         ThisExplorer.StatusBar.Panels(1).Text = ThisExplorer.List.ListItems.Count & " object(s)"
  126.         ThisExplorer.Tree.Nodes(ServerNode.Key).Expanded = True
  127.         
  128.         '---- turn redraw back on
  129.         Call SendMessage(ThisExplorer.Tree.hwnd, WM_SETREDRAW, REDRAWON, 0&)
  130.         Call SendMessage(ThisExplorer.List.hwnd, WM_SETREDRAW, REDRAWON, 0&)
  131.     End If
  132. End Sub
  133. Private Sub ciSession_GotFile(ByVal lpszRemoteFileName As String, ByVal lpszLocalFileName As String)
  134.     Call Status.ShowStatus(Alias & ": the file was successfully received from the FTP server", , , "Status", vbBlue)
  135.     ThisExplorer.MousePointer = vbDefault
  136. End Sub
  137. Private Sub ciSession_InternetError(ByVal error_number As Long, ByVal error_message As String)
  138.     Call Status.ShowStatus(Alias & ": an Internet error occurred - " & error_number, vbRed, True, "Error", vbBlack)
  139.     ThisExplorer.MousePointer = vbDefault
  140. End Sub
  141. Private Sub ciSession_PutFile()
  142.     Call Status.ShowStatus(Alias & ": the file was successfully put on the FTP server", , , "Status", vbBlue)
  143.     ThisExplorer.MousePointer = vbDefault
  144. End Sub
  145. Private Sub ciSession_WSAError(ByVal error_number As Integer)
  146.     Dim ErrString As String
  147.     Dim ErrConstDescription As String
  148.     Dim ErrDescription As String
  149.     ErrDescription = WSAErrDescription(error_number, ErrConstDescription)
  150.     ErrString = Alias & ": a WSA error occurred - " & Format$(error_number, "") & ", " & ErrConstDescription & ": " & ErrDescription
  151.         
  152.     If (error_number = WSAETIMEDOUT) Then
  153.         TimedOut = True
  154.     End If
  155.     Call Status.ShowStatus(ErrString, vbRed, True, "Error", vbBlack)
  156.     ThisExplorer.MousePointer = vbDefault
  157. End Sub
  158. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  159.     ciSession.QUIT
  160. End Sub
  161. Private Sub Form_Terminate()
  162.     '---- explicitly destroy all objects
  163.     Set ServerNode = Nothing
  164.     Set ThisExplorer = Nothing
  165.     Set ThisCallback = Nothing
  166.     Set ThisServer = Nothing
  167. End Sub
  168. '----------------------------------------------------
  169. '<Purpose> forces this form to transfer data from the
  170. ' FTPServer class object into the FTP Control
  171. '----------------------------------------------------
  172. Public Sub InitSession()
  173.     Dim UsingAddress    As Boolean
  174.     Dim UsingName       As Boolean
  175.     Alias = ThisServer.Alias
  176.     '---- name and address are mutually exclusive
  177.     UsingName = (ThisServer.HostName <> "")
  178.     If (Not UsingName) Then
  179.         UsingAddress = (ThisServer.HostAddress <> "")
  180.     End If
  181.     '---- improper settings
  182.     If ((Not UsingName) And (Not UsingAddress)) Then Exit Sub
  183.     '---- if the name did not change, outta here
  184.     If (UsingName And (ciSession.HostName = ThisServer.HostName)) Then Exit Sub
  185.     '---- if the address did not change, outta here
  186.     If (UsingAddress And (ciSession.HostAddress = ThisServer.HostAddress)) Then Exit Sub
  187.     '---- since this is a new host, or address, create a session
  188.     With ciSession
  189.         .HostName = ThisServer.HostName
  190.         .HostAddress = ThisServer.HostAddress
  191.         .LoginName = ThisServer.LoginName
  192.         .Password = ThisServer.Password
  193.         .ServerOSType = ThisServer.ServerType
  194.     End With
  195. End Sub
  196. '-----------------------------------------------------
  197. '<Purpose> creates an FTP connection
  198. '-----------------------------------------------------
  199. Public Sub Connect()
  200.     Connected = False
  201.     GotDirectory = False
  202.     TimedOut = False
  203.     GetListing = True
  204.     If (WorkingDir = "") Then
  205.         ciSession.WorkingDirectory = "/"
  206.     Else
  207.         ciSession.WorkingDirectory = WorkingDir
  208.     End If
  209.     ciSession.GetDirectory
  210.     Call Status.ShowStatus(Alias & ": connecting for directories and files", , , "Status", vbBlue)
  211. End Sub
  212. '------------------------------------------------------
  213. '<Purpose> transfers a file from the PC to the Host
  214. '------------------------------------------------------
  215. Public Sub TransferLocal2Host(LocalFileName As String, FTPDirectory As String, FTPFileName As String)
  216.     Dim TransferFile As String
  217.     '---- allow the user to modify the file name
  218.     TransferFile = InputBox("Host File Name:", "Transfer from My Computer to FTP Server", FTPDirectory & "/" & FTPFileName)
  219.     If (TransferFile = "") Then Exit Sub
  220.     ThisExplorer.MousePointer = vbArrowHourglass
  221.     With ciSession
  222.         .WorkingDirectory = FTPDirectory
  223.         .LocalFileName = LocalFileName
  224.         .RemoteFileName = TransferFile
  225.         .PutFile
  226.     End With
  227.     Call Status.ShowStatus(Alias & ": putting file on server", , , "Status", vbBlue)
  228. End Sub
  229. '------------------------------------------------------
  230. '<Purpose> transfers a file from the Host to the PC
  231. '------------------------------------------------------
  232. Public Sub TransferHost2Local(FTPFileName As String, LocalFileName As String)
  233.     Dim TransferFile As String
  234.     '---- allow the user to modify the file name
  235.     TransferFile = InputBox("Local File Name:", "Transfer from FTP Server to My Computer", LocalFileName)
  236.     If (TransferFile = "") Then Exit Sub
  237.     ThisExplorer.MousePointer = vbArrowHourglass
  238.     With ciSession
  239.         .LocalFileName = TransferFile
  240.         .RemoteFileName = FTPFileName
  241.         .GetFile
  242.     End With
  243.     Call Status.ShowStatus(Alias & ": getting file from server", , , "Status", vbBlue)
  244. End Sub
  245.